//
//  TableCellFrame.m
//  两种Cell间的切换
//
//  Created by 小果 on 16/7/13.
//  Copyright © 2016年 小果. All rights reserved.
//

#import "TableCellFrame.h"
#import "CellModel.h"
@implementation TableCellFrame

-(void)setCellModel:(CellModel *)cellModel{
    
    _cellModel = cellModel;
    
    CGFloat iconX = TabCellMargin;
    CGFloat iconY = TabCellMargin;
    CGFloat iconW = cellIconW;
    CGFloat iconH = cellIconH;
    self.imgF = CGRectMake(iconX, iconY, iconW, iconH);
    
    CGSize nameSize = [cellModel.name sizeWithFont:TnameFont maxSize:CGSizeMake(MAXFLOAT, MAXFLOAT)];
    CGFloat nameX = CGRectGetMaxX(self.imgF) + TabCellMargin;
    CGFloat nameY = iconY;
    self.nameF = CGRectMake(nameX, nameY, nameSize.width, nameSize.height);
    
    CGSize detailSize = [cellModel.detail sizeWithFont:detailFont maxSize:CGSizeMake(MAXFLOAT, MAXFLOAT)];
    CGFloat detailX = nameX;
    CGFloat detailY = CGRectGetMaxY(self.imgF) - detailSize.height;
    self.detailF = CGRectMake(detailX, detailY, detailSize.width, detailSize.height);
    
    CGFloat sepX = 0;
    CGFloat sepY = CGRectGetMaxY(self.imgF) + TabCellMargin;
    CGFloat sepW = ScreenW;
    CGFloat sepH = 1;
    self.sepLine = CGRectMake(sepX, sepY, sepW, sepH);
    
    self.cellHeight = CGRectGetMaxY(self.sepLine);
    
    CGFloat bgValueW = 40;
    CGFloat bgValueH = 40;
    CGFloat bgValueX = ScreenW - TabCellMargin - bgValueW;
    CGFloat bgValueY = (self.cellHeight - bgValueH) * 0.5;
    self.bgValueF = CGRectMake(bgValueX, bgValueY, bgValueW, bgValueH);
    
}

@end
